// 安装babel支持后可按需加载组件
const {
    override,
    fixBabelImports,
    addLessLoader,
    addWebpackPlugin,
    addWebpackAlias
} = require("customize-cra");

const path = require('path');

const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');

// 关闭sourceMap
process.env.GENERATE_SOURCEMAP = "false";

module.exports = override(
    // 配置按需加载antd
    fixBabelImports("antd", {
        libraryDirectory: "es",
        style: true,
    }),
    // 配置less支持
    addLessLoader({
        // lessOptions: { less-loader@6 去掉
        javascriptEnabled: true,
        modifyVars: {
            '@primary-color': '#25b864'
        },
        // },
    }),
    // 使用 Day.js 替换 momentjs 优化打包大小
    addWebpackPlugin(new AntdDayjsWebpackPlugin()),
    // 配置路径别名
    addWebpackAlias({
        ["@"]: path.resolve(__dirname, "./src"),
        ["@pages"]: path.resolve(__dirname, "./src/pages"),
        ["@components"]: path.resolve(__dirname, "./src/components"),
        ["@layout"]: path.resolve(__dirname, "./src/layout"),
        ["@assets"]: path.resolve(__dirname, "./src/assets"),
    })
);